<template>
    <div id='ssssssss' class='i_infoShwo'>
        <div class="title">
            <img :src="build" alt="" srcset="">
            <span>信息公开</span>
        </div>
        <div class="content">
            <Tab :module="'信息公开'" :list="tab" @onClick="changeTab" @addMore="addMore" />
            <div class="list">
                <div v-for="(item,index) in list" :key="index" class="item" @click="onInfoShow(item)">
                    <span class="headline" :title="item.title">
                        {{item.title}}
                        <!-- <Ellipsis :text="item.title" :lines="1" tooltip /> -->
                    </span>
                    <div class="tail">
                        <div class="title">{{item.releaseDept}}</div>
                        <div class="line">|</div>
                        <div class="releaseDate">{{item.releaseDate}}</div>
                    </div>
                </div>
            </div>
            <!-- <div style="font-size: 14px; font-family: PingFang SC-Regular, PingFang SC; font-weight: 400; color: #515A6E;">...</div> -->
        </div>

        <Modal v-model="modalShow" width="1200" :mask-closable="false" :title="modalTitle">
            <components v-if="modalShow" :is="comps" ref="coms" @fileInfo='fileInfo' />
            <div slot="footer">
                <div v-if="isShowFileLoad" class="file">
                    <img :src="pdfImg" alt="">
                    <span @click="downLoad()">附件下载</span>
                </div>
                <div class="btn">
                    <Button @click="cancel">关闭</Button>
                    <!-- <Button class="print-btn" type="primary" @click="print">打印</Button> -->
                </div>
            </div>
        </Modal>

    </div>
</template>
<script>
import Tab from './tab.vue'
import build from '@/assets/svg/fontApp/build_icon.svg'
import infoModal from './detialView/infoShow/detail.vue'
import pdfImg from '@/assets/svg/fontApp/pdf_icon.svg'
import { UpLoad } from '@/mixins/uploadMixins.js'

export default {
    name: '',
    props: [''],
    data() {
        return {
            modalShow: false,
            modalTitle: '',
            comps: infoModal,
            pdfImg: pdfImg,
            build: build,
            list: [],
            tab: [
                { title: '国家法律', default: true },
                { title: '政策解读', default: false },
                { title: '行政法规', default: false },
                { title: '部门规章', default: false },
                { title: '通知公告', default: false },
            ],
            type: "0",
            isShowFileLoad: false,
            loadFile: null,
        };
    },
    components: { Tab },
    computed: {},
    beforeMount() { },
    mounted() {
        this.getList();
    },
    mixins: [UpLoad],
    methods: {

        getList() {
            this.$http.$post('InformationReleasePage', { data: this.requireObj() }).then(res => {
                if (res.code == 200) {
                    this.list = res.data.records ? res.data.records : [];
                }
            })
        },

        // 数据
        requireObj() {
            return {
                "limit": 4,
                "page": 1,
                "type": this.type.split(',')
            }
        },

        changeTab(data) {
            let typeObj = {
                '国家法律': '0',
                '政策解读': '1',
                '行政法规': '2',
                '部门规章': '3',
                '通知公告': '4,5',
            }
            this.type = typeObj[data.title];
            this.getList()
        },

        onInfoShow(event) {
            this.modalShow = true;
            this.isShowFileLoad = false;
            this.$nextTick(() => {
                let typeObj = {
                    '0': '国家法律',
                    '1': '政策解读',
                    '2': '行政法规',
                    '3': '部门规章',
                    '4,5': '通知公告',
                }
                this.$refs.coms.getInfo(event.id, typeObj[this.type])
            })
            // this.$router.push({
            //     path: `/detailInfo/index/信息公开`,
            //     query: {
            //         id: event.id,
            //     }
            // })
        },

        addMore(event) {
            this.$router.push({
                path: `/detailView/index/${event.title}`
            })
        },

        cancel() {
            this.modalShow = false
        },

        fileInfo(file) {
            if (file) {
                this.isShowFileLoad = true;
                this.loadFile = file;
            }
        },

        downLoad() {
            this.downloadUrl(this.loadFile.minioPath, this.loadFile);
        },

        print() {
            this.$refs.coms.print()
        },
    },
    watch: {}
}
</script>
<style lang='less' scoped>
.i_infoShwo {
    width: 50%;
    padding: 20px 10px 20px 20px;
    // background: red;
    .title {
        display: flex;
        align-items: center;
        span {
            margin-left: 10px;
            font-size: 18px;
            font-family: PingFang SC-Bold, PingFang SC;
            font-weight: bold;
            color: #17233d;
        }
        img {
            width: 32px;
            height: 32px;
        }
    }
    .content {
        background: green;
        width: 100%;
        height: 240px;
        margin-top: 15px;
        border-radius: 8px;
        background: #f8f8f9;
        padding: 20px 20px;
        .item {
            display: flex;
            justify-content: space-between;
            height: 35px;
            align-items: center;
            // border-bottom: 1px solid #ccc;
            cursor: pointer;
            .headline {
                width: 65%;
                font-size: 16px;
                font-family: PingFang SC-Regular, PingFang SC;
                color: #515a6e;
                word-break: break-all;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                -o-text-overflow: ellipsis;
            }
            .headline:hover {
                color: #2d8cf0;
            }
            .tail {
                font-size: 16px;
                font-family: PingFang SC-Regular, PingFang SC;
                font-weight: 400;
                color: #808695;
                position: relative;
                width: 200px;
                display: flex;
                justify-content: space-between;
                align-items: center;
                .title {
                    width: 90px;
                    display: flex;
                    justify-content: flex-end;
                }
                .line {
                    margin-bottom: 1px;
                    color: #dcdee2;
                }
                .releaseDate {
                    margin-left: 5px;
                }
            }
        }
        .item:first-child {
            margin-top: 10px;
        }
    }
}
.file {
    cursor: pointer;
    text-align: left;
    img {
        width: 16px;
    }
    span {
        margin-left: 10px;
        font-size: 16px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #3399ff;
    }
}
.btn {
    // text-align: center;
    // .print-btn {
    //     margin-left: 20px;
    // }
}
</style>